package com.liting.uitest.model;

import lombok.Data;

import java.math.BigDecimal;

/**
 * 视觉感知强度的正方形类型
 */
@Data
public class VisionIntentSquare {
    public final static double ChaYi = 0.00001d;

    public final static int Vision_Grade_First = 1;
    public final static int Vision_Grade_Second = 2;
    public final static int Vision_Grade_Third = 3;
    public final static int Vision_Grade_Forth = 4;
    public final static int Vision_Grade_Fifth = 5;
    public final static int Vision_Grade_Sixth = 6;

    private BigDecimal centerX;
    private BigDecimal centerY;
    private BigDecimal sideLength;
    //等级
    private int grade;

    public VisionIntentSquare(BigDecimal tempX, BigDecimal tempY, int grade, BigDecimal sideLength) {
        this.centerX = tempX;
        this.centerY = tempY;
        this.sideLength = sideLength;
        this.grade = grade;

    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof VisionIntentSquare) {
            VisionIntentSquare target = (VisionIntentSquare) obj;
            if ((Math.abs(this.centerY.doubleValue() - target.getCenterY().doubleValue()) < ChaYi)
                    && (Math.abs(this.centerX.doubleValue() - target.getCenterX().doubleValue()) < ChaYi)) {
                return true;
            } else {
                return false;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hashCode = this.centerX.hashCode() + this.centerY.hashCode();
        return hashCode;
    }
}
